<template>
	
	
	<div class="list">
		<div>
			<div class='top'>请填写真实姓名和手机号码</div>
	        <div class='center'>*发放奖励时，系统会验证您的真实姓名和微信实名是否一致，如果不一致将会导致奖励无法发放！</div>
		</div>
		
		
		<div style="position: absolute;left: 0;top: 10rem;width: 81%;padding: 2rem;">
			<div style="background: #E4E4E4;border-radius: 0.3rem;position: relative;margin-bottom: 1rem;">
				<i style="font-size: 1.5rem;" class="iconfont iconfont icon-wo"></i>
				<input v-model="truename" style="position: absolute;top: 0.6rem;font-size: 1rem;border: none;background: #E4E4E4;" placeholder="真实姓名" />
			</div>
			<div style="background: #E4E4E4;border-radius: 0.3rem;position: relative;margin-bottom: 1rem;">
				<i style="font-size: 1.5rem;" class="iconfont icon-shoujihao"></i>
				<input v-model="mobile" style="position: absolute;top: 0.6rem;font-size: 1rem;border: none;background: #E4E4E4;" placeholder="请输入手机号码" />
			</div>
			<div style="margin-bottom: 1rem;">
				<flexbox>
			      <flexbox-item :span="8">
			      	<div class="flex-demo" style="text-align: left;position: relative;background: #E4E4E4;border-radius: 0.3rem;padding-left: 0.1rem;">
				      	<span style="font-size: 1.5rem;" class="iconfont icon-button"></span>
				      	<input v-model="yzm" style="width: 73%;position: absolute;top: 0.6rem;font-size: 1rem;border: none;background: #E4E4E4;"  placeholder="请输入验证码" />
			        </div>
			      </flexbox-item>
			      <flexbox-item><div class="flex-demo" >
			      	<button @click="obtain" style="font-size: 0.8rem;height: 2.25rem;border: none;border-radius: 0.3rem;width: 5rem;color: #FFFFFF;background: #FF9913;margin-top: 0;">获取验证码</button>
			      </div></flexbox-item>
			    </flexbox>
			    
			</div>
			<div style="margin-bottom: 0.5rem;">
				<button @click="register"  style="width: 100%;height: 2.25rem;border: none;background: #FF9913;color: #FFFFFF;border-radius: 0.3rem;font-size: 1.1rem;">修改</button>
			</div>
			
		</div>
	</div>
	
	
	
	
	
	
</template>

<script>
	import { base64} from 'vux'
	export default {
		components: {         
            base64
		},
		data () {
		    return {
		
		      mobile: this.$route.params.mobile,
		      truename:'',
		      access_token:'',
		      yzm:''
		
		    }
		},
		
		methods:{
			
			
			//获取详情
		    getDetail(){
		    	
		    	this.$store.commit('updateLoadingStatus',true);
		    	
		    	this.$http.get(this.$store.state.api + 'userdd/userinfo&access_token=' + this.access_token)
			    .then((response) => {
			    		
			    console.log(response)
					
					if(response.body.code == 0) {
						
//						this.mobile = response.body.data.mobile,
						this.truename = response.body.data.truename
						
					} else {
						
					}
						
					
				this.$store.commit('updateLoadingStatus',false);		
					
				}, (response) => {
	                 
	                 
				});
		    },
			
			
			//获取验证码
            obtain(){
            	console.log(this.mobile);
            	
                    this.$http.post(this.$store.state.api + 'userdd/sms/',
                    {
                    	access_token:this.access_token,
                    	mobile:this.mobile,
                    	type:2
                    })
			        .then(response => {
			          
			           console.log(response);
			  
			         
			        }, response => {
			          
			  
			        });
			    
            },
            
            
            
            
            //修改
            register(){
            	
            	
            	this.$store.commit('updateLoadingStatus',true);
		    	
		    	this.$http.post(this.$store.state.api + 'userlogin/yzm',
                    {
                    	access_token:this.access_token,
                    	mobile:this.mobile,
                    	truename:this.truename,
                    	yzm:this.yzm
                    })
			        .then(response => {
			          
			           console.log(response);
			  
			         
			        }, response => {
			          
			         this.$store.commit('updateLoadingStatus',false);
			         
			        });
            	
           },
           
            //获取地址栏信息
			getUrlStr(name){
		      let reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)","i");
		      if(reg.test(window.location.href)){
		        return unescape(RegExp.$2.replace(/\+/g," "))
		      }
		      return undefined
		    },	
			
			
		},
		
		mounted() {
			
			var access_token = this.getUrlStr('access_token');
           var parentId = this.getUrlStr('parent_id');
           
            if(parentId == undefined){
              parentId = 0;
           }
           
           var uid = this.getUrlStr('uid');
           
           if(parentId.toString().indexOf('?') > 0){
           	 parentId = parentId.split('?')[0];
           }
           
           var locurl = location.href;
           locurl = base64.encode(locurl.split('?')[0]);
           
       
           if(access_token != undefined){
         
              localStorage.setItem("access_token",access_token); 
              localStorage.setItem("parent_id",this.getUrlStr('uid'));


           }
           
            if(localStorage.getItem('access_token') != null){
         
              this.$root.registerjudge();
              this.$root.getShare();
              
            }else{
            	
        	  this.$root.gotoWechat(locurl,parentId);
            }
           
    	   this.access_token = localStorage.getItem('access_token');

	        this.getDetail();
	
	    }
		
	}
	
</script>

<style>
	.list{
	  padding: 1.875rem 2rem
	}
	
	
</style>